// Calculate double operator

#include <iostream>
#include <cstring>
using namespace std;

class Human {
	public:
		Human( int age=0, const char* name="wuming" ) : m_age( age ), m_name( name ){
		
		}
/*
		Human operator+( const Human& that ) const {
			return Human( this->m_age+that.m_age, ( this->m_name+"+"+that.m_name ).c_str());
		}
		*/
		void getInfo( ) {
			cout << "age : " << m_age << endl;
			cout << "name : " << m_name << endl;
		}
	private:
		int m_age;
		string m_name;
		friend Human operator+( const Human& l, const Human& r );
};

// Global
Human operator+( const Human& l, const Human& r ) {
	return Human( l.m_age+r.m_age, (l.m_name+"+"+r.m_name).c_str() );
}

// designer
// ------------------------------------------------------------------
// user

int main( void ) { 
	Human a( 22, "zhangfei" ), b( 24, "zhaoyun" );
        const Human c( 18, "lily" ), d( 50, "guaangjun" );
	
	Human res = a + b;
	res.getInfo( );

	res = c + d;
	res.getInfo( );

	res = Human( 45, "liubei" ) + Human( 35, "huangzhong" );
	res.getInfo( );

	return 0;
}

